import * as NS from "../../Common/NetServices";
import { IsNull } from "../../TYLibrary/Common/GlobalExtend";
import { Wx_XSPPage, V_ReceivingAddress } from "../../Common/Entitys";
import { Log } from "../../TYLibrary/System/Logger";
import { Wx_PageData, WXDataClassRuntimeDecorator } from "../../Common/EntityBase";

@WXDataClassRuntimeDecorator()
class AddressListPageData extends Wx_PageData {
    public AddressList: Array<V_ReceivingAddress> = [];
    public checked1: string = "";
    public checked2: string = "";
}

class AddressList extends Wx_XSPPage {
    public Data: AddressListPageData = new AddressListPageData();

    /**
     * 初始化页面信息
     * @param {*} options
     * @returns {Promise<void>}
     * @memberof AddressList
     */
    public async InitData(options: any): Promise<void> {
        try {
            this.App.ReceivingAddress = await NS.QueryMemberAddress();
            this.Data.AddressList = this.App.ReceivingAddress;
            this.Data.ApplyChange(this);
        } catch (e) {
            this.ShowError(e);
        }
    }

    /**
     *
     * @param {*} e
     * @memberof AddressList
     */
    public CheckAddress1Handler(e: any): void {
        //  let id=e.currentTarget.dataset.id;
        if (this.Data.checked1 == "") {
            this.Data.checked1 = "checked";
        } else {
            this.Data.checked1 = "";
        }
        this.Data.ApplyChange(this);
    }

    /**
     *
     * @param {*} e
     * @memberof AddressList
     */
    public CheckAddress2Handler(e: any): void {
        //  let id=e.currentTarget.dataset.id;
        if (this.Data.checked2 == "") {
            this.Data.checked2 = "checked";
        } else {
            this.Data.checked2 = "";
        }
        this.Data.ApplyChange(this);
    }
}

Page(new AddressList());
